Closed Bug 1342657 Opened 8 years ago Closed 8 years ago

clang-format incorrectly format layout/style/nsCSSPropAliasList.h

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox54 affected, firefox57 fixed)

RESOLVED FIXED
mozilla57
Tracking Status
firefox54 --- affected
firefox57 --- fixed

People

(Reporter: Sylvestre, Assigned: andi)

References

Details

Attachments

(1 file)

-CSS_PROP_ALIAS(-moz-perspective-origin, +CSS_PROP_ALIAS(-moz - perspective - origin, Which is obviously breaking the build.
the build fails with: File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/other-licenses/ply/ply/yacc.py", line 263, in parse return self.parseopt(input,lexer,debug,tracking,tokenfunc) File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/other-licenses/ply/ply/yacc.py", line 792, in parseopt tok = self.errorfunc(errtoken) File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/dom/bindings/parser/WebIDL.py", line 6770, in p_error raise WebIDLError("invalid syntax", [Location(self.lexer, p.lineno, p.lexpos, self._filename)]) WebIDL.WebIDLError: error: invalid syntax, /home/sylvestre/dev/mozilla/mozilla-central.else.change/obj-x86_64-pc-linux-gnu/dom/bindings/CSS2Properties.webidl line 5:90 [Throws, TreatNullAs=EmptyString, BinaryName="alignContent"] attribute DOMString _align - content; ^ Makefile:55 : la recette pour la cible « codegen.pp » a échouée
Reverting the indentation of layout/style/nsCSSPropAliasList.h & layout/style/nsCSSPropList.h fixes the issue
Test case void foo() { --- CSS_PROP_ALIAS(-moz-perspective-origin, "bar"); } --- clang-format-5.0 foo.cpp void foo() { CSS_PROP_ALIAS(-moz - perspective - origin, "bar"); }
#define DO_PROP(name, method, id, flags, pref, proptype) \ [ #name, #method, #id, PROP_STRINGIFY(flags), pref, proptype ] #define CSS_PROP_ALIAS(name, id, method, pref) \ DO_PROP(name, method, id, 0, pref, "alias")
Assignee: nobody → bpostelnicu
The problem here is that clang-format is built on a token stream based processing so it cannot distinguish a function call from a macro call, thus in this case it believes that: >>CSS_PROP_ALIAS(-moz-perspective-origin, >> "bar"); It's a function call, and the first parameters is analysed as an expression that leads to the literal to be indented. Taking all of this into account I think the best approach would be to change the names of the variables/ literals involved.
Comment on attachment 8898257 [details] Bug 1342657 - clang-format: Ignore two files which are using some #define trick https://reviewboard.mozilla.org/r/169628/#review175630 Thank you and sorry for the delay!
Attachment #8898257 - Flags: review?(bpostelnicu) → review+
Pushed by sledru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2c00fbd09ddc clang-format: Ignore two files which are using some #define trick r=andi
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: